[Ext.tree.TreePanel] getNodeById does not work

Posted by Moon on Stack Overflow See other posts from Stack Overflow or by Moon
Published on 2010-04-14T04:43:17Z Indexed on 2010/12/25 6:54 UTC
Read the original article Hit count: 195

Filed under:

Hi,

I have a ext treepanel with json.

var tree = new Ext.tree.TreePanel({
renderTo:'tree-container',
title: 'Category',
height: 300,
width: 400,
useArrows:true,
autoScroll:true,
animate:true,
enableDD:true,
containerScroll: true,
rootVisible: false,
frame: true,
root: {
    text: 'Category',
    draggable: false,
    id: '0'
},

// auto create TreeLoader
dataUrl: $("#web").val() + "/category/index/get-nodes",

listeners: {
    'checkchange': function(node, checked){
        if(checked){
                categoryManager.add(node.id);
            //node.getUI().addClass('complete');
        }else{
                categoryManager.remove(node.id);
           // node.getUI().removeClass('complete');
        }
    }
}

});

dataUrl loads the following json code

[{"text":"Code Snippet","id":"1","cls":"folder","checked":false,"children":[{"text":"PHP","id":"3","cls":"file","checked":false,"children":[]},{"text":"Javascript","id":"4","cls":"file","checked":false,"children":[]}]}]

when I try to find a node by console.log( tree.getNodeByid(3) ), it shows that it is undefined.

Do I have a problem with my code?

© Stack Overflow or respective owner

Related posts about JavaScript